package org.csu.spring.demo.aop.test;

import org.csu.spring.demo.aop.persistence.AccountDao;
import org.csu.spring.demo.aop.persistence.AccountDaoImpl;
import org.csu.spring.demo.aop.proxy.ProxyDemo;
import org.csu.spring.demo.ioc.domain.Account;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import javax.annotation.Resource;
import java.lang.reflect.Proxy;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:applicationContext-aop.xml")
public class demo {
    @Resource(name = "demoAfterProxy")
    private AccountDao accountDao;
    @Test
    public void test(){
//        AccountDao accountDao=new AccountDaoImpl();
//
//        Class class1=accountDao.getClass();
//
//        Object object=Proxy.newProxyInstance(class1.getClassLoader(),class1.getInterfaces(),new ProxyDemo(accountDao));
//
//        accountDao=(AccountDao) object;

        accountDao.find();
    }

}